//
//  ReportViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/28.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "ReportViewController.h"
#import "TagView.h"
@interface ReportViewController ()<TagViewDelegate,UITextViewDelegate,UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *botom_ScroView;
@property (weak, nonatomic) IBOutlet UIView *contentView1;
@property (weak, nonatomic) IBOutlet UIView *roleView;
- (IBAction)select_Host:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIButton *host_Btn;
- (IBAction)select_Businon:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIButton *bussion_Btn;
@property(assign)BOOL expand;
@property(nonatomic,strong)TagView *tags;
@property(nonatomic,strong)NSMutableArray *dataSouce;
@property(nonatomic,strong)NSMutableArray *contetnData;
@property(nonatomic,strong)NSString *rason_Id;
@end

@implementation ReportViewController
-(NSMutableArray *)dataSouce{
    if(!_dataSouce){
        _dataSouce = [NSMutableArray array];
    }
    return _dataSouce;
}
-(NSMutableArray *)contetnData{
    if(!_contetnData){
        _contetnData =[NSMutableArray array];
    }
    return _contetnData;
}
-(TagView *)tags{
if (!_tags) {
    _tags = [[TagView alloc]initWithFrame:CGRectMake(0,0 , screen_width, 0)];
    _tags.delegate = self;
    [self.tagVIews addSubview:_tags];
    
}
return _tags;
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.view endEditing:1];
}
- (void)viewDidLoad {
    [super viewDidLoad];
     [self setNavigation:1 andTitle:@"举报" andNaviColor:[UIColor whiteColor] andTitleColor:nil];
    self.content_Tf.delegate = self;
    self.botom_ScroView.delegate = self;
    self.botom_ScroView.contentSize = CGSizeMake(0, screen_height*1.1);
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideKb)];
    [self.view addGestureRecognizer:tap];
    [self loadType];
    // Do any additional setup after loading the view from its nib.
}
-(void)hideKb{
    [self.view endEditing:1];
}
-(void)loadType{
//http://dev.sharepanzer.com/api/bzapi.php?i=10&c=entry&ctrl=live&ac=store&op=activity&m=bz_activities&token=194d7d75d1b6ac4ed794a53732af625e&ta=get_report_type
   
    NSDictionary *paramter = @{@"op":@"activity",@"ctrl":@"live",@"ac":@"store",@"ta":@"get_report_type"};
    [self weqPostHandle:paramter success:^(id response) {
        if(response){
            if(response){
                NSArray *lists = response[@"data"];
                if(lists.count>0){
                    [self.dataSouce addObjectsFromArray:lists];
                    for(int i=0;i<lists.count;i++){
                        NSDictionary *dic = lists[i];
                        [self.contetnData addObject:dic[@"title"]];
                    }
                    [self reloadTag];
                }
            }
        }
    } failure:^(NSError *error) {
        
    }];
}
-(void)reloadTag{
    [self.tags setArr:self.contetnData];
    self.tagVIews.frame = CGRectMake(0, 50, screen_width, self.tags.frame.size.height+10);
    self.contentView1.frame = CGRectMake(0, self.contentView1.frame.origin.y, screen_width, self.tags.frame.size.height+70);
    self.input_View.frame = CGRectMake(0, self.contentView1.frame.origin.y+self.tags.frame.size.height+70+10, screen_width, self.input_View.frame.size.height);
    
    
}
-(void)handleSelectTag:(NSString *)keyWord andTag:(NSInteger)index AndPindex:(NSInteger)pindex{
    self.rason_Id = self.dataSouce[index][@"id"];
    
}
-(void)textViewDidBeginEditing:(UITextView *)textView{
    self.hide_Lab.hidden = 1;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)select_Host:(UIButton *)sender {
    sender.selected = !sender.selected;
    self.bussion_Btn.selected = 0;
}
- (IBAction)select_Businon:(UIButton *)sender {
    sender.selected = !sender.selected;
    self.host_Btn.selected = 0;
}
-(void)relativeIView:(BOOL)open{
    CGRect content_OldRect = self.contentView1.frame;
     CGRect role_OldRect = self.roleView.frame;
     CGRect tagview_OldRect = self.tagVIews.frame;
    if(open){
        self.roleView.frame = CGRectMake(0, role_OldRect.origin.y, role_OldRect.size.width, 80);
    }else{
        self.roleView.frame = CGRectMake(0, role_OldRect.origin.y, role_OldRect.size.width, 0);
    }
}
- (IBAction)selectRoles:(UIButton *)sender {
    self.expand = !self.expand;
    [self relativeIView:self.expand];
}
- (IBAction)comit:(Regular_Btn *)sender {
    [self hideKb];
//http://dev.sharepanzer.com/api/bzapi.php?i=10&c=entry&ctrl=live&ac=store&op=activity&m=bz_activities&token=194d7d75d1b6ac4ed794a53732af625e&ta=do_report
    NSDictionary *paramter = @{@"op":@"activity",@"ctrl":@"live",@"ac":@"store",@"ta":@"do_report",@"act_id":self.act_id,@"type_id":self.rason_Id,@"anchor_id":self.anchor_id,@"des":self.content_Tf.text};
    [self weqPostHandle:paramter success:^(id response) {
        if(response){
            [WToast showWithText:@"举报成功"];
            [self.navigationController popViewControllerAnimated:1];
        }
    } failure:^(NSError *error) {
        
    }];
}
@end
